﻿using System;
using System.Runtime.InteropServices;

namespace PVTLibrary
{

    [Serializable]
    [ComVisible(true)]
    public abstract class SimulationObjects_BaseClass : ICloneable, IDisposable
    {
        public enum PropertyType
        {
            RO = 0,
            RW = 1,
            WR = 2,
            ALL = 3
        };

        protected string _componentDescription;
        protected string _componentName;

        public const string ClassId = "";

        protected bool m_showqtable = true;


        public abstract string GetProperties(PropertyType proptype);
        public abstract object GetPropertyValue(string prop, Unidades su = null);
        public abstract object GetPropertyUnit(string prop,  Unidades su = null);
        public abstract object SetPropertyValue(string prop, object propval, Unidades su = null);


        /// <summary>
        /// 
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public string FT(string prop, string unit)
        {
            return prop + " (" + unit + ")";
        }

        public string Descricao
        {
            get
            {
                return _componentDescription;
            }
            set
            {
                _componentDescription = value;
            }
        }

        public string Nome
        {
            get
            {
                return _componentName;
            }
            set
            {
                _componentName = value;
            }
        }



        public object Clone()
        {
            return null;
            //modif adel
            //Return ObjectCopy(this);

        }

        public void Dispose()
        {
            
        }

        //modif adel
        /*
        Function ObjectCopy(ByVal obj As SimulationObjects_BaseClass) As SimulationObjects_BaseClass

            Dim objMemStream As New MemoryStream(50000)
            Dim objBinaryFormatter As New BinaryFormatter(Nothing, New StreamingContext(StreamingContextStates.Clone))

            objBinaryFormatter.Serialize(objMemStream, obj)

            objMemStream.Seek(0, SeekOrigin.Begin)

            ObjectCopy = objBinaryFormatter.Deserialize(objMemStream)

            objMemStream.Close()

        End Function

    Public disposedValue As Boolean = False        ' To detect redundant calls

    ' IDisposable
    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: free other state (managed objects).
            End If

            ' TODO: free your own state (unmanaged objects).
            ' TODO: set large fields to null.
        End If
        Me.disposedValue = True
    End Sub

#Region "   IDisposable Support "
    ' This code added by Visual Basic to correctly implement the disposable pattern.
    Public Sub Dispose() Implements IDisposable.Dispose
        ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub
#End Region*/
    }

}